home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / gsword.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  20KB  |  675 lines

  1. /* Great Swordsman (Taito) 1984
  2.  
  3. Credits:
  4. - Steve Ellenoff: Original emulation and Mame driver
  5. - Jarek Parchanski: Dip Switch Fixes, Color improvements, ADPCM Interface code
  6. - Tatsuyuki Satoh: sound improvements, NEC 8741 emulation,adpcm improvements
  7. - Charlie Miltenberger: sprite colors improvements & precious hardware
  8.             information and screenshots
  9.  
  10. Trick:
  11. If you want fight with ODILION swordsman patch program for 1st CPU
  12. at these addresses, otherwise you won't never fight with him.
  13.  
  14.         ROM[0x2256] = 0
  15.         ROM[0x2257] = 0
  16.         ROM[0x2258] = 0
  17.         ROM[0x2259] = 0
  18.         ROM[0x225A] = 0
  19.  
  20.  
  21. There are 3 Z80s and two AY-3-8910s..
  22.  
  23. Prelim memory map (last updated 6/15/98)
  24. *****************************************
  25. GS1        z80 Main Code    (8K)    0000-1FFF
  26. Gs2     z80 Game Data   (8K)    2000-3FFF
  27. Gs3     z80 Game Data   (8K)    4000-5FFF
  28. Gs4     z80 Game Data   (8K)    6000-7FFF
  29. Gs5     z80 Game Data   (4K)    8000-8FFF
  30. Gs6     Sprites         (8K)
  31. Gs7     Sprites         (8K)
  32. Gs8        Sprites            (8K)
  33. Gs10    Tiles            (8K)
  34. Gs11    Tiles            (8K)
  35. Gs12    3rd z80 CPU &   (8K)
  36.         ADPCM Samples?
  37. Gs13    ADPCM Samples?  (8K)
  38. Gs14    ADPCM Samples?  (8K)
  39. Gs15    2nd z80 CPU     (8K)    0000-1FFF
  40. Gs16    2nd z80 Data    (8K)    2000-3FFF
  41. *****************************************
  42.  
  43. **********
  44. *Main Z80*
  45. **********
  46.  
  47.     9000 - 9fff    Work Ram
  48.         982e - 982e Free play
  49.         98e0 - 98e0 Coin Input
  50.         98e1 - 98e1 Player 1 Controls
  51.         98e2 - 98e2 Player 2 Controls
  52.         9c00 - 9c30 (Hi score - Scores)
  53.         9c78 - 9cd8 (Hi score - Names)
  54.         9e00 - 9e7f Sprites in working ram!
  55.         9e80 - 9eff Sprite X & Y in working ram!
  56.  
  57.     a000 - afff    Sprite RAM & Video Attributes
  58.         a000 - a37F    ???
  59.         a380 - a77F    Sprite Tile #s
  60.         a780 - a7FF    Sprite Y & X positions
  61.         a980 - a980    Background Tile Bank Select
  62.         ab00 - ab00    Background Tile Y-Scroll register
  63.         ab80 - abff    Sprite Attributes(X & Y Flip)
  64.  
  65.     b000 - b7ff    Screen RAM
  66.     b800 - ffff    not used?!
  67.  
  68. PORTS:
  69. 7e 8741-#0 data port
  70. 7f 8741-#1 command / status port
  71.  
  72. *************
  73. *2nd Z80 CPU*
  74. *************
  75. 0000 - 3FFF ROM CODE
  76. 4000 - 43FF WORK RAM
  77.  
  78. write
  79. 6000 adpcm sound command for 3rd CPU
  80.  
  81. PORTS:
  82. 00 8741-#2 data port
  83. 01 8741-#2 command / status port
  84. 20 8741-#3 data port
  85. 21 8741-#3 command / status port
  86. 40 8741-#1 data port
  87. 41 8741-#1 command / status port
  88.  
  89. read:
  90. 60 fake port #0 ?
  91. 61 ay8910-#0 read port
  92. data / ay8910-#0 read
  93. 80 fake port #1 ?
  94. 81 ay8910-#1 read port
  95.  
  96. write:
  97. 60 ay8910-#0 controll port
  98. 61 ay8910-#0 data port
  99. 80 ay8910-#1 controll port
  100. 81 ay8910-#1 data port
  101.    ay8910-A  : NMI controll ?
  102. a0 unknown
  103. e0 unknown (watch dog?)
  104.  
  105. *************
  106. *3rd Z80 CPU*
  107. *************
  108. 0000-5fff ROM
  109.  
  110. read:
  111. a000 adpcm sound command
  112.  
  113. write:
  114. 6000 MSM5205 reset and data
  115.  
  116. *************
  117. I8741 communication data
  118.  
  119. reg: 0->1 (main->2nd) /     : (1->0) 2nd->main :
  120.  0 : DSW.2 (port)           : DSW.1(port)
  121.  1 : DSW.1                  : DSW.2
  122.  2 : IN0 / sound error code :
  123.  3 : IN1 / ?                :
  124.  4 : IN2                    :
  125.  4 : IN3                    :
  126.  5 :                        :
  127.  6 :                        : DSW0?
  128.  7 :                        : ?
  129.  
  130. ******************************************/
  131.  
  132. #include "driver.h"
  133. #include "vidhrdw/generic.h"
  134. #include "cpu/z80/z80.h"
  135. #include "machine/tait8741.h"
  136.  
  137. void gsword_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  138. int  gsword_vh_start(void);
  139. void gsword_vh_stop(void);
  140. void gsword_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  141. WRITE_HANDLER( gs_charbank_w );
  142. WRITE_HANDLER( gs_videoctrl_w );
  143. WRITE_HANDLER( gs_videoram_w );
  144.  
  145.  
  146. extern size_t gs_videoram_size;
  147. extern size_t gs_spritexy_size;
  148.  
  149. extern unsigned char *gs_videoram;
  150. extern unsigned char *gs_scrolly_ram;
  151. extern unsigned char *gs_spritexy_ram;
  152. extern unsigned char *gs_spritetile_ram;
  153. extern unsigned char *gs_spriteattrib_ram;
  154.  
  155. static int coins;
  156. static int fake8910_0,fake8910_1;
  157. static int gsword_nmi_step,gsword_nmi_count;
  158.  
  159.  
  160. static int gsword_coins_in(void)
  161. {
  162.     /* emulate 8741 coin slot */
  163.     if (readinputport(4)&0xc0)
  164.     {
  165.         logerror("Coin In\n");
  166.         return 0x80;
  167.     }
  168.     logerror("NO Coin\n");
  169.     return 0x00;
  170. }
  171.  
  172. static READ_HANDLER( gsword_8741_2_r )
  173. {
  174.     switch (offset)
  175.     {
  176.     case 0x01: /* start button , coins */
  177.         return readinputport(0);
  178.     case 0x02: /* Player 1 Controller */
  179.         return readinputport(1);
  180.     case 0x04: /* Player 2 Controller */
  181.         return readinputport(3);
  182.     default:
  183.         logerror("8741-2 unknown read %d PC=%04x\n",offset,cpu_get_pc());
  184.     }
  185.     /* unknown */
  186.     return 0;
  187. }
  188.  
  189. static READ_HANDLER( gsword_8741_3_r )
  190. {
  191.     switch (offset)
  192.     {
  193.     case 0x01: /* start button  */
  194.         return readinputport(2);
  195.     case 0x02: /* Player 1 Controller? */
  196.         return readinputport(1);
  197.     case 0x04: /* Player 2 Controller? */
  198.         return readinputport(3);
  199.     }
  200.     /* unknown */
  201.     logerror("8741-3 unknown read %d PC=%04x\n",offset,cpu_get_pc());
  202.     return 0;
  203. }
  204.  
  205. static struct TAITO8741interface gsword_8741interface=
  206. {
  207.     4,         /* 4 chips */
  208.     { TAITO8741_MASTER,TAITO8741_SLAVE,TAITO8741_PORT,TAITO8741_PORT },  /* program mode */
  209.     { 1,0,0,0 },                                 /* serial port connection */
  210.     { input_port_7_r,input_port_6_r,gsword_8741_2_r,gsword_8741_3_r }    /* port handler */
  211. };
  212.  
  213. void machine_init(void)
  214. {
  215.     unsigned char *ROM2 = memory_region(REGION_CPU2);
  216.  
  217.     ROM2[0x1da] = 0xc3; /* patch for rom self check */
  218.     ROM2[0x726] = 0;    /* patch for sound protection or time out function */
  219.     ROM2[0x727] = 0;
  220.  
  221.     TAITO8741_start(&gsword_8741interface);
  222. }
  223.  
  224. void init_gsword(void)
  225. {
  226.     int i;
  227.  
  228.     for(i=0;i<4;i++) TAITO8741_reset(i);
  229.     coins = 0;
  230.     gsword_nmi_count = 0;
  231.     gsword_nmi_step  = 0;
  232. }
  233.  
  234. static int gsword_snd_interrupt(void)
  235. {
  236.     if( (gsword_nmi_count+=gsword_nmi_step) >= 4)
  237.     {
  238.         gsword_nmi_count = 0;
  239.         return Z80_NMI_INT;
  240.     }
  241.     return Z80_IGNORE_INT;
  242. }
  243.  
  244. static WRITE_HANDLER( gsword_nmi_set_w )
  245. {
  246.     switch(data)
  247.     {
  248.     case 0x02:
  249.         /* needed to disable NMI for memory check */
  250.         gsword_nmi_step  = 0;
  251.         gsword_nmi_count = 0;
  252.         break;
  253.     case 0x0d:
  254.     case 0x0f:
  255.         gsword_nmi_step  = 4;
  256.         break;
  257.     case 0xfe:
  258.     case 0xff:
  259.         gsword_nmi_step  = 4;
  260.         break;
  261.     }
  262.     /* bit1= nmi disable , for ram check */
  263.     logerror("NMI controll %02x\n",data);
  264. }
  265.  
  266. static WRITE_HANDLER( gsword_AY8910_control_port_0_w )
  267. {
  268.     AY8910_control_port_0_w(offset,data);
  269.     fake8910_0 = data;
  270. }
  271. static WRITE_HANDLER( gsword_AY8910_control_port_1_w )
  272. {
  273.     AY8910_control_port_1_w(offset,data);
  274.     fake8910_1 = data;
  275. }
  276.  
  277. static READ_HANDLER( gsword_fake_0_r )
  278. {
  279.     return fake8910_0+1;
  280. }
  281. static READ_HANDLER( gsword_fake_1_r )
  282. {
  283.     return fake8910_1+1;
  284. }
  285.  
  286. WRITE_HANDLER( gsword_adpcm_data_w )
  287. {
  288.     MSM5205_data_w (0,data & 0x0f); /* bit 0..3 */
  289.     MSM5205_reset_w(0,(data>>5)&1); /* bit 5    */
  290.     MSM5205_vclk_w(0,(data>>4)&1);  /* bit 4    */
  291. }
  292.  
  293. WRITE_HANDLER( adpcm_soundcommand_w )
  294. {
  295.     soundlatch_w(0,data);
  296.     cpu_set_nmi_line(2, PULSE_LINE);
  297. }
  298.  
  299. static struct MemoryReadAddress gsword_readmem[] =
  300. {
  301.     { 0x0000, 0x8fff, MRA_ROM },
  302.     { 0x9000, 0x9fff, MRA_RAM },
  303.     { 0xb000, 0xb7ff, MRA_RAM },
  304.     { -1 }    /* end of table */
  305. };
  306.  
  307. static struct MemoryWriteAddress gsword_writemem[] =
  308. {
  309.     { 0x0000, 0x8fff, MWA_ROM },
  310.     { 0x9000, 0x9fff, MWA_RAM },
  311.     { 0xa380, 0xa3ff, MWA_RAM, &gs_spritetile_ram },
  312.     { 0xa780, 0xa7ff, MWA_RAM, &gs_spritexy_ram, &gs_spritexy_size },
  313.     { 0xa980, 0xa980, gs_charbank_w },
  314.     { 0xaa80, 0xaa80, gs_videoctrl_w },    /* flip screen, char palette bank */
  315.     { 0xab00, 0xab00, MWA_RAM, &gs_scrolly_ram },
  316.     { 0xab80, 0xabff, MWA_RAM, &gs_spriteattrib_ram },
  317.     { 0xb000, 0xb7ff, gs_videoram_w, &gs_videoram, &gs_videoram_size },
  318.     { -1 }    /* end of table */
  319. };
  320.  
  321. static struct MemoryReadAddress readmem_cpu2[] =
  322. {
  323.     { 0x0000, 0x3fff, MRA_ROM },
  324.     { 0x4000, 0x43ff, MRA_RAM },
  325.     { -1 }
  326. };
  327.  
  328. static struct MemoryWriteAddress writemem_cpu2[] =
  329. {
  330.     { 0x0000, 0x3fff, MWA_ROM },
  331.     { 0x4000, 0x43ff, MWA_RAM },
  332.     { 0x6000, 0x6000, adpcm_soundcommand_w },
  333.     { -1 }
  334. };
  335.  
  336. static struct MemoryReadAddress readmem_cpu3[] =
  337. {
  338.     { 0x0000, 0x5fff, MRA_ROM },
  339.     { 0xa000, 0xa000, soundlatch_r },
  340.     { -1 }
  341. };
  342.  
  343. static struct MemoryWriteAddress writemem_cpu3[] =
  344. {
  345.     { 0x0000, 0x5fff, MWA_ROM },
  346.     { 0x8000, 0x8000, gsword_adpcm_data_w },
  347.     { -1 }
  348. };
  349.  
  350. static struct IOReadPort readport[] =
  351. {
  352.     { 0x7e, 0x7f, TAITO8741_0_r },
  353.     { -1 }
  354. };
  355.  
  356. static struct IOWritePort writeport[] =
  357. {
  358.     { 0x7e, 0x7f, TAITO8741_0_w },
  359.     { -1 }
  360. };
  361.  
  362. static struct IOReadPort readport_cpu2[] =
  363. {
  364.     { 0x00, 0x01, TAITO8741_2_r },
  365.     { 0x20, 0x21, TAITO8741_3_r },
  366.     { 0x40, 0x41, TAITO8741_1_r },
  367.     { 0x60, 0x60, gsword_fake_0_r },
  368.     { 0x61, 0x61, AY8910_read_port_0_r },
  369.     { 0x80, 0x80, gsword_fake_1_r },
  370.     { 0x81, 0x81, AY8910_read_port_1_r },
  371.     { 0xe0, 0xe0, IORP_NOP }, /* ?? */
  372.     { -1 }
  373. };
  374.  
  375. static struct IOWritePort writeport_cpu2[] =
  376. {
  377.     { 0x00, 0x01, TAITO8741_2_w },
  378.     { 0x20, 0x21, TAITO8741_3_w },
  379.     { 0x40, 0x41, TAITO8741_1_w },
  380.     { 0x60, 0x60, gsword_AY8910_control_port_0_w },
  381.     { 0x61, 0x61, AY8910_write_port_0_w },
  382.     { 0x80, 0x80, gsword_AY8910_control_port_1_w },
  383.     { 0x81, 0x81, AY8910_write_port_1_w },
  384.     { 0xa0, 0xa0, IOWP_NOP }, /* ?? */
  385.     { 0xe0, 0xe0, IOWP_NOP }, /* watch dog ?*/
  386.     { -1 }
  387. };
  388.  
  389. INPUT_PORTS_START( gsword )
  390.     PORT_START    /* IN0 (8741-2 port1?) */
  391.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
  392.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
  393.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  394.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  395.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  396.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  397.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  398.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_HIGH, IPT_COIN1, 1 )
  399.     PORT_START    /* IN1 (8741-2 port2?) */
  400.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  401.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_2WAY )
  402.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  403.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON3 )
  404.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
  405.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 )
  406.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  407.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_HIGH, IPT_COIN1, 1 )
  408.     PORT_START    /* IN2 (8741-3 port1?) */
  409.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
  410.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
  411.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  412.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  413.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  414.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  415.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_HIGH, IPT_COIN1, 1 )
  416.     PORT_START    /* IN3  (8741-3 port2?) */
  417.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_2WAY | IPF_COCKTAIL )
  418.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_2WAY | IPF_COCKTAIL )
  419.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  420.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_COCKTAIL )
  421.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
  422.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL )
  423.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  424.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_HIGH, IPT_COIN1, 1 )
  425.     PORT_START    /* IN4 (coins) */
  426.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  427.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  428.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  429.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  430.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  431.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  432.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  433.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_HIGH, IPT_COIN1, 1 )
  434.  
  435.     PORT_START    /* DSW0 */
  436.     /* NOTE: Switches 0 & 1, 6,7,8 not used      */
  437.     /*     Coins configurations were handled      */
  438.     /*     via external hardware & not via program */
  439.     PORT_DIPNAME( 0x1c, 0x00, DEF_STR( Coin_A ) )
  440.     PORT_DIPSETTING(    0x1c, DEF_STR( 5C_1C ) )
  441.     PORT_DIPSETTING(    0x18, DEF_STR( 4C_1C ) )
  442.     PORT_DIPSETTING(    0x14, DEF_STR( 2C_1C ) )
  443.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  444.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
  445.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_4C ) )
  446.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_5C ) )
  447.  
  448.     PORT_START      /* DSW1 */
  449.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
  450.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  451.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  452.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
  453.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  454.     PORT_DIPSETTING(    0x02, DEF_STR( On ) )
  455.     PORT_DIPNAME( 0x0c, 0x04, "Stage 1 Difficulty" )
  456.     PORT_DIPSETTING(    0x00, "Easy" )
  457.     PORT_DIPSETTING(    0x04, "Normal" )
  458.     PORT_DIPSETTING(    0x08, "Hard" )
  459.     PORT_DIPSETTING(    0x0c, "Hardest" )
  460.     PORT_DIPNAME( 0x10, 0x10, "Stage 2 Difficulty" )
  461.     PORT_DIPSETTING(    0x00, "Easy" )
  462.     PORT_DIPSETTING(    0x10, "Hard" )
  463.     PORT_DIPNAME( 0x20, 0x20, "Stage 3 Difficulty" )
  464.     PORT_DIPSETTING(    0x00, "Easy" )
  465.     PORT_DIPSETTING(    0x20, "Hard" )
  466.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
  467.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  468.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  469.     PORT_DIPNAME( 0x80, 0x00, "Free Game Round" )
  470.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  471.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  472.  
  473.     PORT_START      /* DSW2 */
  474.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
  475.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  476.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  477.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
  478.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  479.     PORT_DIPSETTING(    0x02, DEF_STR( On ) )
  480.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Free_Play ) )
  481.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  482.     PORT_DIPSETTING(    0x04, DEF_STR( On ) )
  483.     PORT_DIPNAME( 0x08, 0x00, DEF_STR( Cabinet ) )
  484.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  485.     PORT_DIPSETTING(    0x08, DEF_STR( Cocktail ) )
  486.     PORT_DIPNAME( 0x30, 0x00, "Stage Begins" )
  487.     PORT_DIPSETTING(    0x00, "Fencing" )
  488.     PORT_DIPSETTING(    0x10, "Kendo" )
  489.     PORT_DIPSETTING(    0x20, "Rome" )
  490.     PORT_DIPSETTING(    0x30, "Kendo" )
  491.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Flip_Screen ) )
  492.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  493.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  494.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  495.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  496.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  497. INPUT_PORTS_END
  498.  
  499. static struct GfxLayout gsword_text =
  500. {
  501.     8,8,    /* 8x8 characters */
  502.     1024,    /* 1024 characters */
  503.     2,      /* 2 bits per pixel */
  504.     { 0, 4 },    /* the two bitplanes for 4 pixels are packed into one byte */
  505.     { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3 },
  506.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  507.     16*8    /* every char takes 16 bytes */
  508. };
  509.  
  510. static struct GfxLayout gsword_sprites1 =
  511. {
  512.     16,16,   /* 16x16 sprites */
  513.     64*2,    /* 128 sprites */
  514.     2,       /* 2 bits per pixel */
  515.     { 0, 4 },    /* the two bitplanes for 4 pixels are packed into one byte */
  516.     { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
  517.             16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3},
  518.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  519.             32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 },
  520.     64*8     /* every sprite takes 64 bytes */
  521. };
  522.  
  523. static struct GfxLayout gsword_sprites2 =
  524. {
  525.     32,32,    /* 32x32 sprites */
  526.     64,       /* 64 sprites */
  527.     2,       /* 2 bits per pixel */
  528.     { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */
  529.     { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
  530.             16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3,
  531.             64*8+0, 64*8+1, 64*8+2, 64*8+3, 72*8+0, 72*8+1, 72*8+2, 72*8+3,
  532.             80*8+0, 80*8+1, 80*8+2, 80*8+3, 88*8+0, 88*8+1, 88*8+2, 88*8+3},
  533.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  534.             32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8,
  535.             128*8, 129*8, 130*8, 131*8, 132*8, 133*8, 134*8, 135*8,
  536.             160*8, 161*8, 162*8, 163*8, 164*8, 165*8, 166*8, 167*8 },
  537.     64*8*4    /* every sprite takes (64*8=16x6)*4) bytes */
  538. };
  539.  
  540. static struct GfxDecodeInfo gfxdecodeinfo[] =
  541. {
  542.     { REGION_GFX1, 0, &gsword_text,         0, 64 },
  543.     { REGION_GFX2, 0, &gsword_sprites1,  64*4, 64 },
  544.     { REGION_GFX3, 0, &gsword_sprites2,  64*4, 64 },
  545.     { -1 } /* end of array */
  546. };
  547.  
  548.  
  549.  
  550. static struct AY8910interface ay8910_interface =
  551. {
  552.     2,        /* 2 chips */
  553.     1500000,    /* 1.5 MHZ */
  554.     { 30, 30 },
  555.     { 0,0 },
  556.     { 0,0 },
  557.     { 0,gsword_nmi_set_w }, /* portA write */
  558.     { 0,0 }
  559. };
  560.  
  561. static struct MSM5205interface msm5205_interface =
  562. {
  563.     1,                /* 1 chip             */
  564.     384000,                /* 384KHz verified!   */
  565.     { 0 },                /* interrupt function */
  566.     { MSM5205_SEX_4B },        /* vclk input mode    */
  567.     { 60 }
  568. };
  569.  
  570.  
  571.  
  572. static struct MachineDriver machine_driver_gsword =
  573. {
  574.     /* basic machine hardware */
  575.     {
  576.         {
  577.             CPU_Z80,
  578.             3000000,
  579.             gsword_readmem,gsword_writemem,
  580.             readport,writeport,
  581.             interrupt,1
  582.         },
  583.         {
  584.             CPU_Z80,
  585.             3000000,
  586.             readmem_cpu2,writemem_cpu2,
  587.             readport_cpu2,writeport_cpu2,
  588.             gsword_snd_interrupt,4
  589.         },
  590.         {
  591.             CPU_Z80 | CPU_AUDIO_CPU,
  592.             3000000,
  593.             readmem_cpu3,writemem_cpu3,
  594.             0,0,
  595.             ignore_interrupt,0
  596.         }
  597.     },
  598.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  599.     200,                                 /* Allow time for 2nd cpu to interleave*/
  600.     machine_init,
  601.  
  602.     /* video hardware */
  603.     32*8, 32*8,{ 0*8, 32*8-1, 2*8, 30*8-1 },
  604.  
  605.     gfxdecodeinfo,
  606.     256, 64*4+64*4,
  607.     gsword_vh_convert_color_prom,
  608.     VIDEO_TYPE_RASTER,
  609.     0,
  610.     gsword_vh_start,
  611.     gsword_vh_stop,
  612.     gsword_vh_screenrefresh,
  613.  
  614.     /* sound hardware */
  615.     0,0,0,0,
  616.     {
  617.         {
  618.             SOUND_AY8910,
  619.             &ay8910_interface
  620.         },
  621.         {
  622.             SOUND_MSM5205,
  623.             &msm5205_interface
  624.         }
  625.     }
  626.  
  627. };
  628.  
  629. /***************************************************************************
  630.  
  631.   Game driver(s)
  632.  
  633. ***************************************************************************/
  634.  
  635. ROM_START( gsword )
  636.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64K for main CPU */
  637.     ROM_LOAD( "gs1",          0x0000, 0x2000, 0x565c4d9e )
  638.     ROM_LOAD( "gs2",          0x2000, 0x2000, 0xd772accf )
  639.     ROM_LOAD( "gs3",          0x4000, 0x2000, 0x2cee1871 )
  640.     ROM_LOAD( "gs4",          0x6000, 0x2000, 0xca9d206d )
  641.     ROM_LOAD( "gs5",          0x8000, 0x1000, 0x2a892326 )
  642.  
  643.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64K for 2nd CPU */
  644.     ROM_LOAD( "gs15",         0x0000, 0x2000, 0x1aa4690e )
  645.     ROM_LOAD( "gs16",         0x2000, 0x2000, 0x10accc10 )
  646.  
  647.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64K for 3nd z80 */
  648.     ROM_LOAD( "gs12",         0x0000, 0x2000, 0xa6589068 )
  649.     ROM_LOAD( "gs13",         0x2000, 0x2000, 0x4ee79796 )
  650.     ROM_LOAD( "gs14",         0x4000, 0x2000, 0x455364b6 )
  651.  
  652.     ROM_REGION( 0x4000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  653.     ROM_LOAD( "gs10",         0x0000, 0x2000, 0x517c571b )    /* tiles */
  654.     ROM_LOAD( "gs11",         0x2000, 0x2000, 0x7a1d8a3a )
  655.  
  656.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  657.     ROM_LOAD( "gs6",          0x0000, 0x2000, 0x1b0a3cb7 )    /* sprites */
  658.  
  659.     ROM_REGION( 0x4000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  660.     ROM_LOAD( "gs7",          0x0000, 0x2000, 0xef5f28c6 )
  661.     ROM_LOAD( "gs8",          0x2000, 0x2000, 0x46824b30 )
  662.  
  663.     ROM_REGION( 0x0360, REGION_PROMS )
  664.     ROM_LOAD( "ac0-1.bpr",    0x0000, 0x0100, 0x5c4b2adc )    /* palette low bits */
  665.     ROM_LOAD( "ac0-2.bpr",    0x0100, 0x0100, 0x966bda66 )    /* palette high bits */
  666.     ROM_LOAD( "ac0-3.bpr",    0x0200, 0x0100, 0xdae13f77 )    /* sprite lookup table */
  667.     ROM_LOAD( "003",          0x0300, 0x0020, 0x43a548b8 )    /* address decoder? not used */
  668.     ROM_LOAD( "004",          0x0320, 0x0020, 0x43a548b8 )    /* address decoder? not used */
  669.     ROM_LOAD( "005",          0x0340, 0x0020, 0xe8d6dec0 )    /* address decoder? not used */
  670. ROM_END
  671.  
  672.  
  673.  
  674. GAMEX( 1984, gsword, 0, gsword, gsword, gsword, ROT0, "Taito Corporation", "Great Swordsman", GAME_IMPERFECT_COLORS )
  675.